package com.itheima;

import java.util.Random;

public class Test2 {
    public static void main(String[] args) {
        //完成生成随机验证码的功能
        String Code =generateCode(4);
        System.out.println(Code);
    }

    public static String generateCode(int n){
        Random random = new Random();

        String code = "";


        for (int i = 0; i < n; i++) {
            int type = random.nextInt(3);

            switch (type){
                case 0:
                    code += random.nextInt(10);
                    break;
                case 1:
                    char ch1 =(char)(random.nextInt(26) + 65);
                    code += ch1;
                    break;
                case 2:
                    char ch2 =(char)(random.nextInt(26) + 97);
                    code += ch2;
                    break;
            }

        }
        return code;
    }





}

